package com.example.core.utils;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class IOUtils {

    /****
     * 获取流传递的参数
     * @param request
     */
    public static String getData(HttpServletRequest request) {
        StringBuilder result = new StringBuilder();
        BufferedReader in = null;
        try {
            in = new BufferedReader(new InputStreamReader(request.getInputStream()));
            String jsonStr = null;
            while ((jsonStr = in.readLine()) != null) {
                result.append(jsonStr);
            }
            in.close();
        } catch (Exception exception) {
            exception.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return result.toString();
    }
}
